package com.gitee.wsl.time.chinese

import kotlin.test.Test
import kotlin.test.assertEquals


/**
 * 农历测试
 *
 * @author 6tail
 */
class LunarTest {
    @Test
    fun test() {
        val date = Lunar(2019, 3, 27, 0, 0, 0)
        assertEquals("二〇一九年三月廿七", date.toString())
        assertEquals(
            "二〇一九年三月廿七 己亥(猪)年 戊辰(龙)月 戊戌(狗)日 子(鼠)时 纳音[平地木 大林木 平地木 桑柘木] 星期三 西方白虎 星宿[参水猿](吉) 彭祖百忌[戊不受田田主不祥 戌不吃犬作怪上床] 喜神方位[巽](东南) 阳贵神方位[艮](东北) 阴贵神方位[坤](西南) 福神方位[艮](东北) 财神方位[坎](正北) 冲[(壬辰)龙] 煞[北]",
            date.toFullString()
        )
        assertEquals("2019-05-01", date.solar.toString())
        assertEquals("2019-05-01 00:00:00 星期三 (劳动节) 金牛座", date.solar.toFullString())
    }

    @Test
    fun test1() {
        val solar = Solar(1, 1, 1, 12, 0, 0)
        assertEquals("〇年冬月十八", solar.lunar.toString())
    }

    @Test
    fun test2() {
        val solar = Solar(9999, 12, 31, 12, 0, 0)
        assertEquals("九九九九年腊月初二", solar.lunar.toString())
    }

    @Test
    fun test3() {
        val lunar = Lunar(0, 11, 18, 12, 0, 0)
        assertEquals("0001-01-01", lunar.solar.toString())
    }

    @Test
    fun test4() {
        val lunar = Lunar(9999, 12, 2, 12, 0, 0)
        assertEquals("9999-12-31", lunar.solar.toString())
    }

    @Test
    fun test5() {
        val lunar = Lunar(1905, 1, 1, 12, 0, 0)
        assertEquals("1905-02-04", lunar.solar.toString())
    }

    @Test
    fun test6() {
        val lunar = Lunar(2038, 12, 29, 12, 0, 0)
        assertEquals("2039-01-23", lunar.solar.toString())
    }

    @Test
    fun test7() {
        val lunar = Lunar(2020, -4, 2, 13, 0, 0)
        assertEquals("二〇二〇年闰四月初二", lunar.toString())
        assertEquals("2020-05-24", lunar.solar.toString())
    }

    @Test
    fun test8() {
        val lunar = Lunar(2020, 12, 10, 13, 0, 0)
        assertEquals("二〇二〇年腊月初十", lunar.toString())
        assertEquals("2021-01-22", lunar.solar.toString())
    }

    @Test
    fun test9() {
        val lunar = Lunar(1500, 1, 1, 12, 0, 0)
        assertEquals("1500-01-31", lunar.solar.toString())
    }

    @Test
    fun test10() {
        val lunar = Lunar(1500, 12, 29, 12, 0, 0)
        assertEquals("1501-01-18", lunar.solar.toString())
    }

    @Test
    fun test11() {
        val solar = Solar(1500, 1, 1, 12, 0, 0)
        assertEquals("一四九九年腊月初一", solar.lunar.toString())
    }

    @Test
    fun test12() {
        val solar = Solar(1500, 12, 31, 12, 0, 0)
        assertEquals("一五〇〇年腊月十一", solar.lunar.toString())
    }

    @Test
    fun test13() {
        val solar = Solar(1582, 10, 4, 12, 0, 0)
        assertEquals("一五八二年九月十八", solar.lunar.toString())
    }

    @Test
    fun test14() {
        val solar = Solar(1582, 10, 15, 12, 0, 0)
        assertEquals("一五八二年九月十九", solar.lunar.toString())
    }

    @Test
    fun test15() {
        val lunar = Lunar(1582, 9, 18, 12, 0, 0)
        assertEquals("1582-10-04", lunar.solar.toString())
    }

    @Test
    fun test16() {
        val lunar = Lunar(1582, 9, 19, 12, 0, 0)
        assertEquals("1582-10-15", lunar.solar.toString())
    }

    @Test
    fun test17() {
        val lunar = Lunar(2019, 12, 12, 11, 22, 0)
        assertEquals("2020-01-06", lunar.solar.toString())
    }

    @Test
    fun test18() {
        val lunar = Lunar(2021, 12, 29)
        assertEquals("除夕", lunar.festivals.get(0))
    }

    @Test
    fun test19() {
        val lunar = Lunar(2020, 12, 30)
        assertEquals("除夕", lunar.festivals.get(0))
    }

    @Test
    fun test20() {
        val lunar = Lunar(2020, 12, 29)
        assertEquals(0, lunar.festivals.size)
    }

    @Test
    fun test21() {
        val solar = Solar.fromYmd(2022, 1, 31)
        val lunar = solar.lunar
        assertEquals("除夕", lunar.festivals.get(0))
    }

    @Test
    fun test22() {
        val lunar = Lunar.fromYmd(2033, -11, 1)
        assertEquals("2033-12-22", lunar.solar.toYmd())
    }

    @Test
    fun test25() {
        val solar = Solar(2021, 6, 7, 21, 18, 0)
        val lunar = solar.lunar
        assertEquals("二〇二一年四月廿七", lunar.toString())
    }

    @Test
    fun test26() {
        val lunar = Lunar.fromYmdHms(2021, 6, 7, 21, 18, 0)
        val solar = lunar.solar
        assertEquals("2021-07-16", solar.toString())
    }

    @Test
    fun testNext() {
        val solar = Solar(2020, 1, 10, 12, 0, 0)
        val lunar = solar.lunar
        for (i in -50..49) {
            assertEquals("推移天数：" + i, solar.next(i).lunar.toFullString(), lunar.next(i).toFullString())
        }
    }

    @Test
    fun test27() {
        val solar = Solar.fromYmd(1989, 4, 28)
        val lunar = solar.lunar
        assertEquals(23, lunar.day)
    }

    @Test
    fun test28() {
        val solar = Solar.fromYmd(1990, 10, 8)
        val lunar = solar.lunar
        assertEquals("乙酉", lunar.monthInGanZhiExact)
    }

    @Test
    fun test29() {
        val solar = Solar.fromYmd(1990, 10, 9)
        val lunar = solar.lunar
        assertEquals("丙戌", lunar.monthInGanZhiExact)
    }

    @Test
    fun test30() {
        val solar = Solar.fromYmd(1990, 10, 8)
        val lunar = solar.lunar
        assertEquals("丙戌", lunar.monthInGanZhi)
    }

    @Test
    fun test31() {
        val solar = Solar.fromYmdHms(1987, 4, 17, 9, 0, 0)
        val lunar = solar.lunar
        assertEquals("一九八七年三月二十", lunar.toString())
    }

    @Test
    fun test32() {
        val lunar = Lunar.fromYmd(2034, 1, 1)
        assertEquals("2034-02-19", lunar.solar.toYmd())
    }

    @Test
    fun test33() {
        val lunar = Lunar.fromYmd(2033, 12, 1)
        assertEquals("2034-01-20", lunar.solar.toYmd())
    }

    @Test
    fun test34() {
        val lunar = Lunar.fromYmd(37, -12, 1)
        assertEquals("闰腊", lunar.monthInChinese)
    }

    @Test
    fun test35() {
        var lunar = Lunar.fromYmd(56, -12, 1)
        assertEquals("闰腊", lunar.monthInChinese)

        lunar = Lunar.fromYmd(75, -11, 1)
        assertEquals("闰冬", lunar.monthInChinese)

        lunar = Lunar.fromYmd(94, -11, 1)
        assertEquals("闰冬", lunar.monthInChinese)

        lunar = Lunar.fromYmd(94, 12, 1)
        assertEquals("腊", lunar.monthInChinese)

        lunar = Lunar.fromYmd(113, 12, 1)
        assertEquals("腊", lunar.monthInChinese)

        lunar = Lunar.fromYmd(113, -12, 1)
        assertEquals("闰腊", lunar.monthInChinese)

        lunar = Lunar.fromYmd(5552, -12, 1)
        assertEquals("闰腊", lunar.monthInChinese)
    }

    @Test
    fun test36() {
        val solar = Solar.fromYmd(5553, 1, 22)
        val lunar = solar.lunar
        assertEquals("五五五二年闰腊月初二", lunar.toString())
    }

    @Test
    fun test37() {
        val solar = Solar.fromYmd(7013, 12, 24)
        val lunar = solar.lunar
        assertEquals("七〇一三年闰冬月初四", lunar.toString())
    }

    @Test
    fun test38() {
        val lunar = Lunar.fromYmd(7013, -11, 4)
        val solar = lunar.solar
        assertEquals("7013-12-24", solar.toString())
    }

    @Test
    fun test39() {
        val solar = Solar.fromYmd(1987, 4, 12)
        val lunar = solar.lunar
        assertEquals("一九八七年三月十五", lunar.toString())
    }

    @Test
    fun test40() {
        val solar = Solar.fromYmd(1987, 4, 13)
        val lunar = solar.lunar
        assertEquals("一九八七年三月十六", lunar.toString())
    }

    @Test
    fun test41() {
        val solar = Solar.fromYmd(4, 2, 10)
        val lunar = solar.lunar
        assertEquals("鼠", lunar.yearShengXiao)
    }

    @Test
    fun test42() {
        val solar = Solar.fromYmd(4, 2, 9)
        val lunar = solar.lunar
        assertEquals("猪", lunar.yearShengXiao)
    }

    @Test
    fun test43() {
        val solar = Solar.fromYmd(1, 2, 12)
        val lunar = solar.lunar
        assertEquals("鸡", lunar.yearShengXiao)
    }

    @Test
    fun test44() {
        val solar = Solar.fromYmd(1, 1, 1)
        val lunar = solar.lunar
        assertEquals("猴", lunar.yearShengXiao)
    }

    @Test
    fun test45() {
        val solar = Solar.fromYmd(1946, 9, 30)
        val lunar = solar.lunar
        assertEquals("一九四六年九月初六", lunar.toString())
    }

    @Test
    fun test46() {
        val solar = Solar.fromYmd(1946, 9, 29)
        val lunar = solar.lunar
        assertEquals("一九四六年九月初五", lunar.toString())
    }

    @Test
    fun test47() {
        val solar = Solar.fromYmd(2017, 2, 15)
        val lunar = solar.lunar
        assertEquals("子命互禄 辛命进禄", lunar.dayLu)
    }

    @Test
    fun test48() {
        val solar = Solar.fromYmd(2021, 11, 13)
        val lunar = solar.lunar
        assertEquals("碓磨厕 外东南", lunar.dayPositionTai)
    }

    @Test
    fun test49() {
        val solar = Solar.fromYmd(2021, 11, 12)
        val lunar = solar.lunar
        assertEquals("占门碓 外东南", lunar.dayPositionTai)
    }

    @Test
    fun test50() {
        val solar = Solar.fromYmd(2021, 11, 13)
        val lunar = solar.lunar
        assertEquals("西南", lunar.dayPositionFuDesc)
    }

    @Test
    fun test51() {
        val solar = Solar.fromYmd(2021, 11, 12)
        val lunar = solar.lunar
        assertEquals("正北", lunar.dayPositionFuDesc)
    }

    @Test
    fun test52() {
        val solar = Solar.fromYmd(2011, 11, 12)
        val lunar = solar.lunar
        assertEquals("厨灶厕 外西南", lunar.dayPositionTai)
    }

    @Test
    fun test53() {
        val solar = Solar.fromYmd(2021, 11, 27)
        val lunar = solar.lunar
        assertEquals(
            "[嫁娶, 祭祀, 祈福, 求嗣, 开光, 出行, 解除, 出火, 拆卸, 进人口, 入宅, 移徙, 安床, 栽种, 动土, 修造, 纳畜, 入殓, 安葬, 立碑, 除服, 成服]",
            lunar.dayYi.toString()
        )
    }

//    @Test
//    @Throws(ParseException::class)
//    fun test54() {
//        val format: SimpleDateFormat = SimpleDateFormat("yyyy-MM-dd")
//        format.setTimeZone(TimeZone.getTimeZone("GMT+8"))
//        val date: Date? = format.parse("1986-08-14")
//        val lunar: Lunar = Lunar(date)
//        assertEquals("一九八六年七月初九", lunar.toString())
//    }

    @Test
    fun test55() {
        val solar = Solar(1986, 8, 14)
        val lunar = solar.lunar
        assertEquals("一九八六年七月初九", lunar.toString())
    }

    @Test
    fun test56() {
        val solar = Solar(2022, 4, 5)
        val lunar = solar.lunar
        assertEquals("甲辰", lunar.monthInGanZhi)
        assertEquals("癸卯", lunar.monthInGanZhiExact)
        assertEquals("[出火, 入宅, 安葬, 伐木]", lunar.dayJi.toString())
    }

    @Test
    fun test57() {
        val solar = Solar(1991, 2, 5)
        val lunar = solar.lunar
        assertEquals("庚寅", lunar.monthInGanZhi)
    }

    @Test
    fun test58() {
        val solar = Solar(2021, 3, 21)
        val lunar = solar.lunar
        assertEquals("春社", lunar.otherFestivals.get(0))
    }

    @Test
    fun test59() {
        val solar = Solar(2022, 3, 16)
        val lunar = solar.lunar
        assertEquals("春社", lunar.otherFestivals.get(0))
    }

    @Test
    fun test60() {
        val solar = Solar(1722, 9, 25)
        val lunar = solar.lunar
        assertEquals("秋社", lunar.otherFestivals.get(0))
    }

    @Test
    fun test61() {
        val solar = Solar(840, 9, 14)
        val lunar = solar.lunar
        assertEquals("秋社", lunar.otherFestivals.get(0))
    }

    @Test
    fun test62() {
        val lunar = Lunar.fromYmd(1582, 9, 18)
        assertEquals("1582-10-04", lunar.solar.toString())
    }

    @Test
    fun test63() {
        val lunar = Lunar.fromYmd(1582, 9, 19)
        assertEquals("1582-10-15", lunar.solar.toString())
    }

    @Test
    fun test64() {
        val lunar = Lunar.fromYmd(1518, 1, 1)
        assertEquals("1518-02-10", lunar.solar.toString())
    }

    @Test
    fun test65() {
        val lunar = Lunar.fromYmd(793, 1, 1)
        assertEquals("0793-02-15", lunar.solar.toString())
    }

    @Test
    fun test66() {
        val lunar = Lunar.fromYmd(2025, -6, 1)
        assertEquals("2025-07-25", lunar.solar.toString())
    }

    @Test
    fun test67() {
        val lunar = Lunar.fromYmd(2025, 6, 1)
        assertEquals("2025-06-25", lunar.solar.toString())
    }

    @Test
    fun test68() {
        val lunar = Lunar.fromYmd(193, 1, 1)
        assertEquals("0193-02-19", lunar.solar.toString())
    }

    @Test
    fun test69() {
        val lunar = Lunar.fromYmd(288, 1, 1)
        assertEquals("0288-02-19", lunar.solar.toString())
    }

    @Test
    fun test70() {
        val lunar = Lunar.fromYmd(755, 1, 1)
        assertEquals("0755-02-16", lunar.solar.toString())
    }

    @Test
    fun test71() {
        val lunar = Lunar.fromYmd(41, 1, 1)
        assertEquals("0041-02-20", lunar.solar.toString())
    }

    @Test
    fun test72() {
        val lunar = Lunar.fromYmd(57, 1, 1)
        assertEquals("0057-02-23", lunar.solar.toString())
    }

    @Test
    fun test73() {
        val lunar = Lunar.fromYmd(345, 1, 1)
        assertEquals("0345-02-18", lunar.solar.toString())
    }

    @Test
    fun test74() {
        val lunar = Lunar.fromYmd(459, 1, 1)
        assertEquals("0459-02-18", lunar.solar.toString())
    }

    @Test
    fun test75() {
        val lunar = Lunar.fromYmd(497, 1, 1)
        assertEquals("0497-02-18", lunar.solar.toString())
    }

    @Test
    fun test76() {
        val lunar = Lunar.fromYmd(516, 1, 1)
        assertEquals("0516-02-18", lunar.solar.toString())
    }

    @Test
    fun test77() {
        val lunar = Lunar.fromYmd(554, 1, 1)
        assertEquals("0554-02-18", lunar.solar.toString())
    }

    @Test
    fun test78() {
        val lunar = Lunar.fromYmd(698, 1, 1)
        assertEquals("0698-02-16", lunar.solar.toString())
    }

    @Test
    fun test79() {
        val lunar = Lunar.fromYmd(793, 1, 1)
        assertEquals("0793-02-15", lunar.solar.toString())
    }

    @Test
    fun test80() {
        val lunar = Lunar.fromYmd(918, 1, 1)
        assertEquals("0918-02-14", lunar.solar.toString())
    }

    @Test
    fun test81() {
        val lunar = Lunar.fromYmd(1013, 1, 1)
        assertEquals("1013-02-13", lunar.solar.toString())
    }

    @Test
    fun test82() {
        val lunar = Lunar.fromYmd(1051, 1, 1)
        assertEquals("1051-02-14", lunar.solar.toString())
    }

    @Test
    fun test83() {
        val lunar = Lunar.fromYmd(1070, 1, 1)
        assertEquals("1070-02-14", lunar.solar.toString())
    }

    @Test
    fun test84() {
        val lunar = Lunar.fromYmd(1127, 1, 1)
        assertEquals("1127-02-13", lunar.solar.toString())
    }

    @Test
    fun test85() {
        val lunar = Lunar.fromYmd(1146, 1, 1)
        assertEquals("1146-02-13", lunar.solar.toString())
    }

    @Test
    fun test86() {
        val lunar = Lunar.fromYmd(1165, 1, 1)
        assertEquals("1165-02-13", lunar.solar.toString())
    }

    @Test
    fun test87() {
        val lunar = Lunar.fromYmd(1423, 1, 1)
        assertEquals("1423-02-11", lunar.solar.toString())
    }

    @Test
    fun test88() {
        val lunar = Lunar.fromYmd(1442, 1, 1)
        assertEquals("1442-02-11", lunar.solar.toString())
    }

    @Test
    fun test89() {
        val lunar = Lunar.fromYmd(1461, 1, 1)
        assertEquals("1461-02-10", lunar.solar.toString())
    }

    @Test
    fun test90() {
        val lunar = Lunar.fromYmd(1556, 1, 1)
        assertEquals("1556-02-11", lunar.solar.toString())
    }

    @Test
    fun test91() {
        val lunar = Lunar.fromYmd(1537, 1, 1)
        assertEquals("1537-02-10", lunar.solar.toString())
    }

    @Test
    fun test92() {
        val lunar: Lunar = Solar.fromYmd(917, 12, 1).lunar
        assertEquals("九一七年闰十月十四", lunar.toString())
    }

    @Test
    fun test93() {
        val lunar: Lunar = Solar.fromYmd(917, 12, 31).lunar
        assertEquals("九一七年冬月十五", lunar.toString())
    }

    @Test
    fun test94() {
        val lunar: Lunar = Solar.fromYmd(918, 1, 1).lunar
        assertEquals("九一七年冬月十六", lunar.toString())
    }

    @Test
    fun test95() {
        val lunar: Lunar = Solar.fromYmd(2023, 10, 30).lunar
        assertEquals("闭", lunar.zhiXing)
    }

    @Test
    fun test96() {
        val lunar: Lunar = Solar.fromYmd(2025, 2, 7).lunar
        assertEquals(
            "[嫁娶, 祭祀, 祈福, 出行, 解除, 出火, 拆卸, 动土, 入宅, 移徙, 安床, 上梁, 栽种, 纳畜, 破土, 启钻, 安葬]",
            lunar.dayYi.toString()
        )
        assertEquals("[开市, 立券, 理发, 作灶]", lunar.dayJi.toString())
    }

    @Test
    fun test97() {
        val lunar: Lunar = Solar.fromYmd(2025, 3, 5).lunar
        assertEquals("[破屋, 坏垣, 求医, 治病]", lunar.dayYi.toString())
        assertEquals("[诸事不宜]", lunar.dayJi.toString())
    }

    @Test
    fun test98() {
        val lunar: Lunar = Solar.fromYmd(2025, 5, 3).lunar
        assertEquals("[祭祀, 祈福, 求嗣, 斋醮, 沐浴, 纳畜, 入殓, 破土, 安葬]", lunar.dayYi.toString())
        assertEquals("[移徙, 入宅, 嫁娶, 出行, 安床]", lunar.dayJi.toString())
    }

    @Test
    fun test99() {
        val lunar: Lunar = Solar.fromYmd(2025, 5, 4).lunar
        assertEquals(
            "[纳采, 祭祀, 祈福, 求嗣, 斋醮, 出行, 起基, 盖屋, 定磉, 安门, 入殓, 安葬]",
            lunar.dayYi.toString()
        )
        assertEquals("[嫁娶, 开市, 纳财, 出火]", lunar.dayJi.toString())
    }

    @Test
    fun test100() {
        val solar = Solar(2025, 9, 16)
        val lunar = solar.lunar
        assertEquals("[时德, 阳德, 民日, 玉宇, 司命]", lunar.dayJiShen.toString())
        assertEquals("[河魁, 死神, 天吏, 致死, 往亡]", lunar.dayXiongSha.toString())
    }
}
